$.ajaxSetup({
   headers:{
       'X-CSRF-TOKEN' : $('meta[name="csrf-token"]').attr('content')
   }
});

//审核
$(".post-audit").click(function(event){
    var target = $(event.target);
    var post_id = target.attr("post-id");
    var status = target.attr("post-action-status");

    $.ajax({
        url : "/admin/posts/" + post_id + "/status",
        method : "post",
        data : {"status": status},
        dataType : "json",
        success : function (data) {
            if(data.code == 200) {
                alert(data.msg);
                target.parents('tr').remove();
            }else {
                alert(data);
            }

        },
        error : function () {
            alert('操作失败');
        }
    });
});

//删除专题
$(".topic-delete").click(function(event){
    if(confirm("确定要执行删除操作么？") == false) {
        return ;
    }

    var target = $(event.target);
    event.preventDefault();
    var url = target.attr("delete-url");

    $.ajax({
       url : url,
       method : "POST",
       data: {"_method" : "DELETE"},
       dataType : "json",
       success: function (data) {
           if(data.code == 200) {
               alert(data.msg)
               target.parents('tr').remove();
           } else {
               alert(data)
           }
       },
       error : function () {
           alert('操作失败');
       }
    });

});